/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: WHY
 * Date: 2023-05-22
 * Time: 22:35
 */
//二叉树先序遍历
public class TestDemo {
    public static void main(String[] args) {
        public static void preOrderUnRecur(Node head) {
            System.out.print("pre-order: ");
            if (head != null) {
                Stack<Node> stack = new Stack<Node>();
                stack.add(head);
                while (!stack.isEmpty()) {
                    head = stack.pop();
                    System.out.print(head.value + " ");
                    if (head.right != null) {
                        stack.push(head.right);
                    }
                    if (head.left != null) {
                        stack.push(head.left);
                    }
                }
            }
            System.out.println();
        }
    }
}
